/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Hogar;

import java.io.*;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.Canvas;
public class Edificio {
private Image planta;
private int habActiva = 1;
private int numHabitaciones;
private int[][] adyacenciaHab;
private int[][] coordenadasHab;
private int[][] coordenadasTemp;
private int[] temperatura;
private int numLuces;
private boolean[] estadoLuz;
private int[][] coordenadasLuz;
private boolean[] alarma;
private boolean video = false;
private boolean microondas = false;
public Edificio() {
numHabitaciones = getNumHabitaciones();
try{
planta = Image.createImage("/planta0.png");
temperatura = new int[numHabitaciones];
alarma = new boolean[numHabitaciones];
adyacenciaHab = new int[numHabitaciones][4];
coordenadasHab = new int[numHabitaciones][4];
coordenadasTemp = new int[numHabitaciones][2];
}
catch (Exception e){
System.out.println("No se pudo crear galería de imágenes");
}
}
public int[] mostrarPlanta(int mov){
int hab = adyacenciaHab[habActiva-1][mov];
if (hab != 0){
habActiva = hab;
return coordenadasHab[hab-1];
}
else return coordenadasHab[habActiva-1];
}
public void establecerTemperatura(int[] temp){
for (int i=0;i<numHabitaciones;i++){
temperatura[i] = temp[i];
}
}
public int getTemperatura(int i){
return temperatura[i];
}
public void setNumLuces(int n){
numLuces = n;
estadoLuz = new boolean[numLuces];
coordenadasLuz = new int[numLuces][2];
}
public int getNumLuces(){
return numLuces;
}
public void setEstadoLuz(boolean[] l){
for (int i=0;i<numHabitaciones;i++){
estadoLuz[i] = l[i];
}
}
public void setCoordLuz(int[][] l){
for (int i=0;i<numLuces;i++){
for (int j=0;j<=1;j++){
coordenadasLuz[i][j] = l[i][j];
}
}
}
public void setAlarma(boolean[] alar){
for (int i=0;i<numHabitaciones;i++){
alarma[i] = alar[i];
}
}
public void setVideo(boolean est){
video = est;
}
public boolean getVideo(){
return video;
}
public void setMicroondas(boolean est){
microondas = est;
}
public boolean getMicroondas(){
return microondas;
}
public void establecerCoord(int[][] coord){
for (int i=0;i<numHabitaciones;i++)
for (int j=0;j<4;j++)
coordenadasHab[i][j] = coord[i][j];
}
public void establecerAdyacencia(int[][] ady){
for (int i=0;i<numHabitaciones;i++)
for (int j=0;j<4;j++)
adyacenciaHab[i][j] = ady[i][j];
}
public void setCoordTemp(int[][] c){
for (int i=0;i<numHabitaciones;i++){
for (int j=0;j<2;j++){
coordenadasTemp[i][j] = c[i][j];
}
}
}
public int[][] getCoordTemp(){
return coordenadasTemp;
}
public int getNumHabitaciones(){
return 4;
}
public Image getPlanta(){
return planta;
}
public int[] getCoordHabActiva(){
return coordenadasHab[habActiva-1];
}
public void setTempHab(int t){
// Enviar datos al servlet
temperatura[habActiva-1] = t;
}
public boolean getAlarmaHab(){
return alarma[habActiva-1];
}
public boolean[] getEstAlarma(){
return alarma;
}
public void setAlarHab(boolean est){
alarma[habActiva-1] = est;
}
}

